﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitView;
using YJKCopyModel.LastFastModeling;

namespace YJKCopyModel.Command
{
	[Transaction(TransactionMode.Manual)]
	public class CmdLastFastModeling : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIDocument activeUIDocument = commandData.Application.ActiveUIDocument;
			Document document = activeUIDocument.Document;
			CommandHelper.SetRevitWorkWindowFocused(activeUIDocument);
			CmdViewType types = (CmdViewType)15;
			bool flag = SwitchView.SetUsableView(types, commandData) > 0;
			Result result;
			if (flag)
			{
				result = Autodesk.Revit.UI.Result.Cancelled;
			}
			else
			{
				LastFastModelingMaker useRequestMaker = new LastFastModelingMaker(commandData);
				QuickModelFrameWork quickModelFrameWork = new QuickModelFrameWork(useRequestMaker, new LastFastModelingRespondHanlder());
				quickModelFrameWork.ExcuteWithWhile(commandData);
				result = Autodesk.Revit.UI.Result.Succeeded;
			}
			return result;
		}
	}
}
